package impleDao;

import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;


import modelo.Promocion;
import dao.PromocionDAO;

public class PromocionImple extends HibernateDaoSupport implements PromocionDAO
{
	
	private static Session session;
	private static Transaction tx;
	
	private void iniciaOperacion() throws HibernateException {
	 	session = getSession();
	 	tx = session.beginTransaction();
	 }

	 private void manejaExcepcion(HibernateException he) throws HibernateException {
		 tx.rollback();
		 throw new HibernateException("ERROR en la capa de acceso a datos", he);
	 }
	@Override
	public List<Promocion> findAll()
	{
		List<Promocion> lst=null;
		try{
			iniciaOperacion();
			lst=session.createQuery("from modelo.Promocion p").list();
		}finally{
			session.close();
		}
		return lst;
	}

}
